Puzzles KO :

Result:Mate 19", "puzzleFenStart" : "8/8/3k4/8/3K4/8/3P4/8 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "King two square in front of pawn = win.
An easy way to remember the key squares is to note that if the pawn is not beyond the midpoint of the board, there are three key squares that are two ranks ahead. If the pawn is on the fifth or sixth rank there are six key squares on the two ranks in front of the pawn. If the pawn is on the seventh rank, the adjoining squares on the seventh and eighth ranks are key squares
", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#2 - Pawn Endgame Class D - Silman endgame", "puzzleInfo" : " White to play = draw (black king will use the opposition to block white king).
Black to play = white win ! The opposition is lost !
An easy way to remember the key squares is to note that if the pawn is not beyond the midpoint of the board, there are three key squares that are two ranks ahead. If the pawn is on the fifth or sixth rank there are six key squares on the two ranks in front of the pawn. If the pawn is on the seventh rank, the adjoining squares on the seventh and eighth ranks are key squares
Result:Draw", "puzzleFenStart" : "8/3k4/8/2K5/3P4/8/8/8 b - - 10 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "White to play = draw (black king will use the opposition to block white king).
Black to play = white win ! The opposition is lost !
An easy way to remember the key squares is to note that if the pawn is not beyond the midpoint of the board, there are three key squares that are two ranks ahead. If the pawn is on the fifth or sixth rank there are six key squares on the two ranks in front of the pawn. If the pawn is on the seventh rank, the adjoining squares on the seventh and eighth ranks are key squares", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#3 - Pawn Endgame Class D - Silman endgame", "puzzleInfo" : " To win : keep the opposition. The square betwin the king and the pawn allow white king to use a xainting move to keep opposition.
An easy way to remember the key squares is to note that if the pawn is not beyond the midpoint of the board, there are three key squares that are two ranks ahead. If the pawn is on the fifth or sixth rank there are six key squares on the two ranks in front of the pawn. If the pawn is on the seventh rank, the adjoining squares on the seventh and eighth ranks are key squares
Result:Mate 16", "puzzleFenStart" : "8/3k4/8/4K3/8/4P3/8/8 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "To win : keep the opposition. The square betwin the king and the pawn allow white king to use a xainting move to keep opposition.
An easy way to remember the key squares is to note that if the pawn is not beyond the midpoint of the board, there are three key squares that are two ranks ahead. If the pawn is on the fifth or sixth rank there are six key squares on the two ranks in front of the pawn. If the pawn is on the seventh rank, the adjoining squares on the seventh and eighth ranks are key squares", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#4 - Knight Pawn Class D - Silman endgame", "puzzleInfo" : " White to move
Don’t allow the black king to go to a draw on a8.
Target : keep the « a » column with the white king 
Result:Mate 20", "puzzleFenStart" : "8/8/2k5/8/KP6/8/8/8 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "White to move
Don’t allow the black king to go to a draw on a8.
Target : keep the « a » column with the white king ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#5 - Fox in the chicken coup Class D - Silman endgame", "puzzleInfo" : " The stronger King (Fox) feast on helpness enemy pawns (chickens) while the defending King is busy dealing with a pawn on other king. 
Result:Mate 18", "puzzleFenStart" : "8/8/1k3p2/5Pp1/KP4P1/8/8/8 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "The stronger King (Fox) feast on helpness enemy pawns (chickens) while the defending King is busy dealing with a pawn on other king. ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#6 - one pawn kill two Class D - Silman endgame", "puzzleInfo" : " Don’t allow your pawn majority to be frozen in it’s track by a smaller number of enemy pawns
Result:Draw", "puzzleFenStart" : "8/8/2k3p1/1p6/1K6/6PP/8/8 w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Don’t allow your pawn majority to be frozen in it’s track by a smaller number of enemy pawns ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#7 - Knight Vs alone Pawn Class D - Silman endgame", "puzzleInfo" : " Rule :
If the Knight can safely land on (or keep connected to) the square (or squares, if the pawn isn’t on the 7th rank) in front of the pawn, the game will be drawn (a rook-pawn being the one case where exceptions might occur). Remember :
If the Knight can safely land on the square in front of the pawn, the game will be draw.
A lone Knight can only triumph over a lone pawn if that pawn is a rook-pawn and if its King is trapped in front of it. Why ? Because, in certain rare instances, the rook-pawn allows smother mates occur.
Result:Draw", "puzzleFenStart" : "7K/8/2N5/8/8/2pk4/8/8 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rule :
If the Knight can safely land on (or keep connected to) the square (or squares, if the pawn isn’t on the 7th rank) in front of the pawn, the game will be drawn (a rook-pawn being the one case where exceptions might occur). Remember :
If the Knight can safely land on the square in front of the pawn, the game will be draw.
A lone Knight can only triumph over a lone pawn if that pawn is a rook-pawn and if its King is trapped in front of it. Why ? Because, in certain rare instances, the rook-pawn allows smother mates occur.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#8 - Rook Vs lone Pawn Class D - Silman endgame", "puzzleInfo" : " Rules : Idea : lock the white king.
The pawn is lost because if it want go to the 8th rank, rook have enough time to capture it without king protection.
Result:Mate 20", "puzzleFenStart" : "8/8/8/6P1/8/5K2/1r6/k7 b - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rules : Idea : lock the white king.
The pawn is lost because if it want go to the 8th rank, rook have enough time to capture it without king protection.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#9 - Short Side/long side defense Class D - Silman endgame", "puzzleInfo" : " Defend white position - King from short side, Rook on long side (rook will make continious check will King try to take the pawn)
White play king to short side and rook to h8 (long side)
Result:draw", "puzzleFenStart" : "7R/8/8/8/2p5/2k5/K7/2r5 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Defend white position - King from short side, Rook on long side (rook will make continious check will King try to take the pawn)
White play king to short side and rook to h8 (long side)", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#10 - King & Pawn VS Lone King Class C - Silman endgame", "puzzleInfo" : " If the stronger side’s king gets one square in front of it’s pawn, the result of the game depends on who has the opposition unless one of two exceptions are present : White to move = win | Black to move = draw (depends on who has the opposition) :
Result:Mate 22", "puzzleFenStart" : "4k3/8/8/8/8/8/4P3/4K3 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "If the stronger side’s king gets one square in front of it’s pawn, the result of the game depends on who has the opposition unless one of two exceptions are present : White to move = win | Black to move = draw (depends on who has the opposition) :", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#11 - King and Two Doubled pawns vs. Lone King Class C - Silman endgame", "puzzleInfo" : " If the the paws are healthy and not rook-pawns, King and 2 doubled pawns win
Result:Mate 15", "puzzleFenStart" : "8/8/6k1/8/6P1/6K1/6P1/8 w - - 3 4", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "If the the paws are healthy and not rook-pawns, King and 2 doubled pawns win ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#12 - Lone King vs Knight and Rook-Pawn on the 6th or 7th Class C - Silman endgame", "puzzleInfo" : " Rule : A knight and a safe pawn vs. A lone King is always a win for the material advantage, except when the extra pawn is a rook-pawn and that rook-pawn is on the 7th rank.
Target : use the pawn promotion threat
black to move = >draw
Useful advice : Strategy : white rook while protected the pawn promotion and block black king. The white king attack the black rook . White king plan : walking to the 1st rank to attack the black king and zigzag to the rook and never go in front og the pawn (and first protect the pawn) → Kc6
Result:Mate 16", "puzzleFenStart" : "6k1/8/7P/1K2N3/8/8/8/8 w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rule : A knight and a safe pawn vs. A lone King is always a win for the material advantage, except when the extra pawn is a rook-pawn and that rook-pawn is on the 7th rank.
Target : use the pawn promotion threat
black to move = >draw
Useful advice : Strategy : white rook while protected the pawn promotion and block black king. The white king attack the black rook . White king plan : walking to the 1st rank to attack the black king and zigzag to the rook and never go in front og the pawn (and first protect the pawn) → Kc6", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#13 - Lucena Position Class C - Silman endgame", "puzzleInfo" : " Position : King + Rook VS non rook-pawn + King + Rook. White king is on 8th rank back the pawn in 7th rank and white King canno’t move.
Steps :
Result:Mate 19", "puzzleFenStart" : "3K4/3P1k2/8/8/8/8/4R3/2r5 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Position : King + Rook VS non rook-pawn + King + Rook. White king is on 8th rank back the pawn in 7th rank and white King canno’t move.
Steps : ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#14 - Lucena Position Puzzle - John Bathelomew", "puzzleInfo" : " Position : King + Rook VS non rook-pawn + King + Rook. White king is on 8th rank back the pawn in 7th rank and white King canno’t move.
Steps :
Result:Mate 15", "puzzleFenStart" : "8/1P2k3/1K6/8/3R4/8/1r6/8 w - - 6 4", "puzzleMoves" : "Kc6 Rc2+ Kb5 Rb2+ Rb4 Rxb4+ Kxb4 Kd7 b8=Q", "puzzleVariations" : " ", "puzzleSolutionComment" : "Position : King + Rook VS non rook-pawn + King + Rook. White king is on 8th rank back the pawn in 7th rank and white King canno’t move.
Steps : ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#15 - Lucena Position Puzzle 2 - John Bathelomew", "puzzleInfo" : " Position : King + Rook VS non rook-pawn + King + Rook. White king is on 8th rank back the pawn in 7th rank and white King canno’t move.
Steps :
Result:Mate", "puzzleFenStart" : "1K6/1P6/8/4k3/3R4/8/8/r7 w - - 6 4", "puzzleMoves" : "Rb4 Kd6 Kc8 Rc1+ Kd8", "puzzleVariations" : " ", "puzzleSolutionComment" : "Position : King + Rook VS non rook-pawn + King + Rook. White king is on 8th rank back the pawn in 7th rank and white King canno’t move.
Steps : ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#16 - Lucena Position Error - Hanging Pawns", "puzzleInfo" : " Black Error after Rg2
Result:Mate 19", "puzzleFenStart" : "4K3/4P3/5k2/8/8/8/6R1/r7 w - - 10 1", "puzzleMoves" : "Kf8 Ra8+ e8=Q Rxe8+ Kxe8", "puzzleVariations" : " ", "puzzleSolutionComment" : "Black Error after Rg2", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#17 - Philidor Position – Draw Class C - Silman endgame", "puzzleInfo" : " Position : King in front of the ennemy pawn.
Though a Philidor position shoud be drawn, things can turn ugly if the defender’s rook becomes passively placed.
Silman Useful advice :
Silman rules :
Philidor = draw ?
Passive rook
Black idea : perpetual check with black rook on the 1st rank.
White idea :

Result:Draw", "puzzleFenStart" : "6R1/4k2r/8/3KP3/8/8/8/8 b - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Position : King in front of the ennemy pawn.
Though a Philidor position shoud be drawn, things can turn ugly if the defender’s rook becomes passively placed.
Silman Useful advice :
Silman rules :
Philidor = draw ?
Passive rook
Black idea : perpetual check with black rook on the 1st rank.
White idea :
", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#18 - Philidor Position – Draw - Hanging Pawns", "puzzleInfo" : "
Result:Draw", "puzzleFenStart" : "4k3/R7/8/7r/8/8/3KP3/8 b - - 1 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#19 - Philidor Position Class C - Silman endgame", "puzzleInfo" : "
Result:Mate 11", "puzzleFenStart" : "3k2r1/7R/2KP4/8/8/8/8/8 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#20 - Queen vs d Pawn Class C - Silman endgame", "puzzleInfo" : " Queen vs Pawn on the 6th Rank
Rule : Lone Queen vs King and pawn on the 6th rank is almost always a win for the Queen.
Queen vs Pawn on the 7th Rank
Rule : This endgame is won by manoeuvring with the Queen so that black’s King is forced to step in front of it’s pawn. Since the pawn can’t move for a moment, the white King can take a safe step closer to the pawn’s position. This will be repeated until white’s King joins with its Queen to pick off the pawn.
Rules :
Astuces :
Result:5773", "puzzleFenStart" : "3K2Q1/8/8/8/8/5k2/3p4/8 w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Queen vs Pawn on the 6th Rank
Rule : Lone Queen vs King and pawn on the 6th rank is almost always a win for the Queen.
Queen vs Pawn on the 7th Rank
Rule : This endgame is won by manoeuvring with the Queen so that black’s King is forced to step in front of it’s pawn. Since the pawn can’t move for a moment, the white King can take a safe step closer to the pawn’s position. This will be repeated until white’s King joins with its Queen to pick off the pawn.
Rules :
Astuces : ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#21 - Queen vs e Pawn Class C - Chess engame Android", "puzzleInfo" : " Queen vs Pawn on the 6th Rank
Rule : Lone Queen vs King and pawn on the 6th rank is almost always a win for the Queen.
Queen vs Pawn on the 7th Rank
Rule : This endgame is won by manoeuvring with the Queen so that black’s King is forced to step in front of it’s pawn. Since the pawn can’t move for a moment, the white King can take a safe step closer to the pawn’s position. This will be repeated until white’s King joins with its Queen to pick off the pawn.
Rules :
Astuces :
Result:Mate 17", "puzzleFenStart" : "8/6K1/8/8/3Q4/8/4p3/2k5 w - - 0 6", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Queen vs Pawn on the 6th Rank
Rule : Lone Queen vs King and pawn on the 6th rank is almost always a win for the Queen.
Queen vs Pawn on the 7th Rank
Rule : This endgame is won by manoeuvring with the Queen so that black’s King is forced to step in front of it’s pawn. Since the pawn can’t move for a moment, the white King can take a safe step closer to the pawn’s position. This will be repeated until white’s King joins with its Queen to pick off the pawn.
Rules :
Astuces : ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#22 - Queen vs f Pawn Class C - Chess engame Android", "puzzleInfo" : " Queen vs Pawn on the 6th Rank
Rule : Lone Queen vs King and pawn on the 6th rank is almost always a win for the Queen.
Queen vs Pawn on the 7th Rank
Rule : This endgame is won by manoeuvring with the Queen so that black’s King is forced to step in front of it’s pawn. Since the pawn can’t move for a moment, the white King can take a safe step closer to the pawn’s position. This will be repeated until white’s King joins with its Queen to pick off the pawn.
Rules :
Astuces :
Result:Mate 14", "puzzleFenStart" : "7Q/1K6/8/8/8/5p2/6k1/8 w - - 0 6", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Queen vs Pawn on the 6th Rank
Rule : Lone Queen vs King and pawn on the 6th rank is almost always a win for the Queen.
Queen vs Pawn on the 7th Rank
Rule : This endgame is won by manoeuvring with the Queen so that black’s King is forced to step in front of it’s pawn. Since the pawn can’t move for a moment, the white King can take a safe step closer to the pawn’s position. This will be repeated until white’s King joins with its Queen to pick off the pawn.
Rules :
Astuces : ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#23 - Queen vs e Pawn Class C - Chess engame Android", "puzzleInfo" : " Queen vs Pawn on the 6th Rank
Rule : Lone Queen vs King and pawn on the 6th rank is almost always a win for the Queen.
Queen vs Pawn on the 7th Rank
Rule : This endgame is won by manoeuvring with the Queen so that black’s King is forced to step in front of it’s pawn. Since the pawn can’t move for a moment, the white King can take a safe step closer to the pawn’s position. This will be repeated until white’s King joins with its Queen to pick off the pawn.
Rules :
Astuces :
Result:Mate 20", "puzzleFenStart" : "8/6K1/8/8/8/8/4pk2/7Q w - - 0 6", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Queen vs Pawn on the 6th Rank
Rule : Lone Queen vs King and pawn on the 6th rank is almost always a win for the Queen.
Queen vs Pawn on the 7th Rank
Rule : This endgame is won by manoeuvring with the Queen so that black’s King is forced to step in front of it’s pawn. Since the pawn can’t move for a moment, the white King can take a safe step closer to the pawn’s position. This will be repeated until white’s King joins with its Queen to pick off the pawn.
Rules :
Astuces : ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#24 - King and two healthy pawn vs lone King Class B - Silman endgame", "puzzleInfo" : " Rule : two passed pawns, on the same rank but separated by one file, have the ability to defend themselves from attacks by the enemy King.
/When the King attack one, push the other and the attacked pawn suddenly becomes poison! Black to move.
Result:Mate 18", "puzzleFenStart" : "8/8/6k1/8/5P1P/8/8/K7 w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rule : two passed pawns, on the same rank but separated by one file, have the ability to defend themselves from attacks by the enemy King.
/When the King attack one, push the other and the attacked pawn suddenly becomes poison! Black to move.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#25 - 2 passed pawns separated by 2 files vs Lone King Class B - Silman endgame", "puzzleInfo" : " Rule : The result of King and two pawns on the same rank two files apart vs. Lone King usually depends on whether or not the stronger side can sacrifice one of his pawns, using the time gained to bring his King into the game and create a winning King and pawn vs. King position.
Result:Mate 18", "puzzleFenStart" : "8/8/5k2/8/4P2P/8/8/7K w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rule : The result of King and two pawns on the same rank two files apart vs. Lone King usually depends on whether or not the stronger side can sacrifice one of his pawns, using the time gained to bring his King into the game and create a winning King and pawn vs. King position.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#26 - 2 passed pawns separated by 2 files vs Lone King – Draw Class B - Silman endgame", "puzzleInfo" : " Rule : The result of King and two pawns on the same rank two files apart vs. Lone King usually depends on whether or not the stronger side can sacrifice one of his pawns, using the time gained to bring his King into the game and create a winning King and pawn vs. King position.
Result:Draw", "puzzleFenStart" : "8/8/6k1/8/4P2P/8/8/7K b - - 0 51", "puzzleMoves" : "Kh5", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rule : The result of King and two pawns on the same rank two files apart vs. Lone King usually depends on whether or not the stronger side can sacrifice one of his pawns, using the time gained to bring his King into the game and create a winning King and pawn vs. King position.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#27 - 2 passed pawns separated by 2 files vs Lone King – Draw Class B - Silman endgame", "puzzleInfo" : " Rule : The result of King and two pawns on the same rank two files apart vs. Lone King usually depends on whether or not the stronger side can sacrifice one of his pawns, using the time gained to bring his King into the game and create a winning King and pawn vs. King position.
Result:Draw", "puzzleFenStart" : "8/8/8/4P2k/7P/8/8/7K b - - 0 52", "puzzleMoves" : "Kg6", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rule : The result of King and two pawns on the same rank two files apart vs. Lone King usually depends on whether or not the stronger side can sacrifice one of his pawns, using the time gained to bring his King into the game and create a winning King and pawn vs. King position.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#28 - 2 passed pawns separated by 3 files vs Lone King Class B - Silman endgame", "puzzleInfo" : " Rule : if the pawns are three or more files apart (and not yet on the 5th rank), the defender loses unless he can immediatly capture one o the pawns.
Result:Mate 15", "puzzleFenStart" : "8/8/5k2/8/3P3P/8/8/7K w - - 9 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rule : if the pawns are three or more files apart (and not yet on the 5th rank), the defender loses unless he can immediatly capture one o the pawns.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#29 - Rook + 2 connected pawns Vs Rook Class B - Silman endgame", "puzzleInfo" : " A Rook endgame where one side is up two connected passed pawns is usually, as you might imagine, a clear win . Surprisingly, it can be quite time consuming and success is often dependent on you knowing the key ideas, and on you avoiding the many stalemate tricks that are lurking in the shadows.
Connected rook-pawns and knight-pawns is the hardest case.
RULE
REMEMBER
USEFUL ADVICE WARNINGStep-by-step winning process: Your plan now is to : Personnal (Thibault) plan :
Result: +12 CP", "puzzleFenStart" : "8/5k2/8/3R3P/5r2/8/6PK/8 w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "A Rook endgame where one side is up two connected passed pawns is usually, as you might imagine, a clear win . Surprisingly, it can be quite time consuming and success is often dependent on you knowing the key ideas, and on you avoiding the many stalemate tricks that are lurking in the shadows.
Connected rook-pawns and knight-pawns is the hardest case.
RULE
REMEMBER
USEFUL ADVICE WARNINGStep-by-step winning process: Your plan now is to : Personnal (Thibault) plan : ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#30 - Rook + 2 connected pawns Vs Rook Class B - Silman endgame", "puzzleInfo" : "
Result:Mate 15", "puzzleFenStart" : "5k2/8/3R2PP/7K/8/8/8/5r2 w - - 1 17", "puzzleMoves" : "h7 Rh1+ Kg5 Ke7 Ra6 Kd7 g7 Rg1+ Kf4 Rf1+ Ke3 Kc7 g8=Q", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#31 - Rook vs bishop the wrong corner - De La Villa – 100 end games", "puzzleInfo" : " Rook vs bishop the wrong corner P39 de la villa.
The ending Rook vs. Bishop is usually a draw. However, the defender has to be careful with some positions when the king is pushed to the edge of the board. This is especially dangerous when the king is pushed to the wrong corner.
In a Rook vs. Bishop ending, the wrong corner is the corner of the same colour as the squares on which the bishop moves.
Result:Mate 19", "puzzleFenStart" : "6k1/5R2/6K1/8/8/8/8/6b1 w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Rook vs bishop the wrong corner P39 de la villa.
The ending Rook vs. Bishop is usually a draw. However, the defender has to be careful with some positions when the king is pushed to the edge of the board. This is especially dangerous when the king is pushed to the wrong corner.
In a Rook vs. Bishop ending, the wrong corner is the corner of the same colour as the squares on which the bishop moves.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#32 - Rook vs bishop right corner - De La Villa – 100 end games", "puzzleInfo" : " The other corner is a completely different story. It is so easy to defend this ending from the right corner that going there straight away is a perfectly sound idea.
Position 1.18 The black king stands in the corner, while the bishop is ready to interpose on g8 in case of a check. Then White would have to let the bishop move to avoid stalemate, and the position wouldbe repeated. There are no serious winning chances.
Result:Draw", "puzzleFenStart" : "7k/R7/7K/8/8/1b6/8/8 b - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "The other corner is a completely different story. It is so easy to defend this ending from the right corner that going there straight away is a perfectly sound idea.
Position 1.18 The black king stands in the corner, while the bishop is ready to interpose on g8 in case of a check. Then White would have to let the bishop move to avoid stalemate, and the position wouldbe repeated. There are no serious winning chances.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#33 - Rook vs night at the edge of the board - De La Villa – 100 end games", "puzzleInfo" : " When fighting against a rook, the knight may have more trouble than the bishop. Nevertheless,most positions are drawn.In this ending, keeping the knight close to the king is the best policy. If the knight is separated from the king, it can be lost.
Result:Draw", "puzzleFenStart" : "8/8/8/8/8/3k4/r7/3NK3 w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "When fighting against a rook, the knight may have more trouble than the bishop. Nevertheless,most positions are drawn.In this ending, keeping the knight close to the king is the best policy. If the knight is separated from the king, it can be lost.", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#34 - Rook vs knight or king in the corner - De La Villa – 100 end games", "puzzleInfo" : " Things are radically different when the king and the knight are at one corner of the board, no matter who occupies the corner-square. Their mobility is then restricted and the position becomes immediately lost. Even if the knight occupies the g2-square (an especially unfortunate square for the knight) most cases result in a defeat.
There is no need for a deep analysis and it does not matter which side is to move: in all these positions White loses the knight straight away. The third diagram is especially impressive: the knight is not even on the edge of the board, but it is lost anyway. This is our first example of a ‘knight’s dumb square’ and its effects, but it will not be the last.
Conclusion: In the battle Knight vs. Rook there are two scenarios the defender should avoid:
Result:Draw", "puzzleFenStart" : "r7/8/8/8/8/6k1/6N1/7K w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Things are radically different when the king and the knight are at one corner of the board, no matter who occupies the corner-square. Their mobility is then restricted and the position becomes immediately lost. Even if the knight occupies the g2-square (an especially unfortunate square for the knight) most cases result in a defeat.
There is no need for a deep analysis and it does not matter which side is to move: in all these positions White loses the knight straight away. The third diagram is especially impressive: the knight is not even on the edge of the board, but it is lost anyway. This is our first example of a ‘knight’s dumb square’ and its effects, but it will not be the last.
Conclusion: In the battle Knight vs. Rook there are two scenarios the defender should avoid: ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#35 - Rook vs knight or king in the corner - De La Villa – 100 end games", "puzzleInfo" : " Things are radically different when the king and the knight are at one corner of the board, no matter who occupies the corner-square. Their mobility is then restricted and the position becomes immediately lost. Even if the knight occupies the g2-square (an especially unfortunate square for the knight) most cases result in a defeat.
There is no need for a deep analysis and it does not matter which side is to move: in all these positions White loses the knight straight away. The third diagram is especially impressive: the knight is not even on the edge of the board, but it is lost anyway. This is our first example of a ‘knight’s dumb square’ and its effects, but it will not be the last.
Conclusion: In the battle Knight vs. Rook there are two scenarios the defender should avoid:
Result:Mate -3", "puzzleFenStart" : "8/8/8/8/8/6k1/r7/6NK w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "Things are radically different when the king and the knight are at one corner of the board, no matter who occupies the corner-square. Their mobility is then restricted and the position becomes immediately lost. Even if the knight occupies the g2-square (an especially unfortunate square for the knight) most cases result in a defeat.
There is no need for a deep analysis and it does not matter which side is to move: in all these positions White loses the knight straight away. The third diagram is especially impressive: the knight is not even on the edge of the board, but it is lost anyway. This is our first example of a ‘knight’s dumb square’ and its effects, but it will not be the last.
Conclusion: In the battle Knight vs. Rook there are two scenarios the defender should avoid: ", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#36 - Workbook Ex4 - De La Villa – Workbook", "puzzleInfo" : "
Result:Mate 26", "puzzleFenStart" : "5K2/7k/8/5b2/8/6R1/8/8 w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#37 - Workbook Ex5 - De La Villa – Workbook", "puzzleInfo" : "
Result:Mate 13", "puzzleFenStart" : "8/8/6Pn/3k1P2/5K2/8/8/8 w - - 1 2", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#38 - Workbook Ex6 - De La Villa – Workbook", "puzzleInfo" : "
Result: + 150 CP", "puzzleFenStart" : "8/6pk/3Q3p/5K2/5P1P/8/8/4r3 w - - 0 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#39 - Exo2 Pawn + king VS Pwn + King - Chess Endgames Apps", "puzzleInfo" : "
Result:Mate", "puzzleFenStart" : "5k2/8/8/p7/8/8/1P6/2K5 w - - 0 19", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#40 - Exo5 Pawn + king VS Pwn + King - Chess Endgames Apps", "puzzleInfo" : "
Result:Mate", "puzzleFenStart" : "8/8/2k1p3/5P2/3K4/8/8/8 w - - 0 19", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#41 - Exo10 Pawn + king VS Pwn + King - Chess Endgames Apps", "puzzleInfo" : "
Result:Mate", "puzzleFenStart" : "8/8/8/8/8/P4p2/k6K/8 w - - 0 19", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#42 - Exo13 Pawn + king VS Pawn + King - Chess Endgames Apps", "puzzleInfo" : "
Result:Mate", "puzzleFenStart" : "8/8/2K2p2/8/7P/8/4k3/8 w - - 0 19", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#43 - Exo16 Pawn + king VS Pwn + King - Chess Endgames Apps", "puzzleInfo" : "
Result:Mate", "puzzleFenStart" : "8/p7/8/8/5P2/8/8/2k2K2 w - - 0 19", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#44 - 2 Pawns VS 1 Pawn - Cours Jean-Claude Moingt", "puzzleInfo" : "
Result:Draw", "puzzleFenStart" : "8/8/3p1k2/3P4/4P1K1/8/8/8 b - - 1 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#45 - 3 Pawns VS 3 Pawns - Cours Jean-Claude Moingt", "puzzleInfo" : "
Result:Draw", "puzzleFenStart" : "8/6pp/5p2/5PP1/4k1KP/8/8/8 w - - 1 2", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#46 - 2 Pawns VS 1 Pawn - Cours Jean-Claude Moingt", "puzzleInfo" : "
Result:Draw", "puzzleFenStart" : "8/8/4p3/6kP/8/7p/7K/8 b - - 1 1", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#47 - Multiple pawns - Parties Lichess", "puzzleInfo" : "
Result:Win", "puzzleFenStart" : "8/8/p1pp4/8/1P5k/2PP1pp1/P4N2/5K2 w - - 0 40", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#48 - Multiple pawns - Parties Lichess", "puzzleInfo" : "
Result:Win", "puzzleFenStart" : "8/8/p1pp4/8/1P6/2PP1pk1/P7/5K2 w - - 0 42", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#49 - Multiple pawns - Parties Lichess", "puzzleInfo" : "
Result:Win", "puzzleFenStart" : "8/8/p1pp4/8/PP3k2/2PP1p2/8/5K2 w - - 1 43", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#50 - 2 bishops mate - puzzle perso", "puzzleInfo" : "
Result:Win", "puzzleFenStart" : "5BB1/8/5K2/8/8/2k5/8/8 w - - 1 19", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#51 - 2 Pawns - puzzle perso", "puzzleInfo" : "
Result:Win", "puzzleFenStart" : "8/6kP/6P1/6K1/8/8/8/8 w - - 13 38", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#52 - Queen VS Knight - puzzle perso", "puzzleInfo" : "
Result:", "puzzleFenStart" : "Q7/8/8/8/8/3k4/7K/5n2 w - - 0 24", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "#53 - King Vs King + 1 pawn - Cours Jean-Claude Moingt", "puzzleInfo" : "
Result:Win", "puzzleFenStart" : "5k2/8/8/8/1P6/8/8/3K4 w - - 0 1", "puzzleMoves" : "Kc2 Ke7 Kb3 Kd6 Ka4 Kc6 Ka5 Kb7 Kb5", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"} ] }; var masteringChessStrategy = { "title" : "Mastering Chess Strategy", "puzzles" : [ { "puzzleTitle" : "1 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "r4rk1/pp1bn1pp/4p3/q2pP3/P1p2P2/2P5/2PBB1PP/R2Q1RK1 b - - 0 15", "puzzleMoves" : "Be8 Bg4 Qb6+ Kh1 Bg6", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "2 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "r2q1rk1/pb3ppp/np1p4/b1pP4/8/P1P1P1P1/4NPBP/1RBQ1RK1 w - - 0 14", "puzzleMoves" : "c4 Nc7 Qc2 Qe7 Be4 h6 Bb2", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "3 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "3r4/1kr1bp1p/3p1p2/p1qPpP2/1p6/1P3QP1/P1PRN2P/1K2R3 b - - 0 29", "puzzleMoves" : "Bf8 c3 Bh6", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "4 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "r1r3k1/1p1b1pqn/p2p2p1/3P3p/n1B1P3/3NBP2/Q5PP/2R2RK1 w - - 0 51", "puzzleMoves" : "Qf2 Nc3 Nb2! Na4?! Bd4", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "5 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "3q1nk1/1p4pp/2p2p2/p1b1pQ2/4P2P/1PP5/P1B2PP1/2B3K1 w - - 0 51", "puzzleMoves" : "a3 g6 Qf3 h5 b4 Bb6 Bb3", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "6 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "r2q1rk1/pb2bppp/1p1pp3/7n/3BPP2/2NP1N2/PP1Q2PP/R4R1K b - - 0 51", "puzzleMoves" : "f5 Be3 Qd7 Nd4 Bf6", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "7 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "2rr2k1/1b3pp1/p2p1b1p/1p2pP2/4P3/P1N5/1PP1BRPP/3R3K b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "8 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "1r4k1/2qbpr1p/p2p2p1/nppPn3/5N2/1P4PP/PB3PB1/R2QR1K1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "9 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "6r1/3bbk2/4p2p/1p1pPp2/2pP1Pr1/P4K2/1P4NP/1R2B1R1 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "10 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "1r1q1rk1/p4pp1/4b2p/nn1Np3/2p1P3/2P5/P1B1QPPP/1RB2RK1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "11 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "1r6/1q2n1bk/p2p1npp/4p3/1r2P3/2NQB1NP/PPRR2P1/1K6 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "12 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "r6r/1p1nkppp/p3pn2/2b5/2B2P2/1PN1P2P/P4P2/R1BR2K1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "13 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "1kr4r/pp2bpp1/q3b2p/n2pPp2/3P3P/PP2BNP1/5PK1/R1NQ3R b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "14 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "2kr3r/ppq5/2n1pn1p/2pp2p1/3P2P1/P1PBPP2/R6P/2BQ1RK1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "15 Bishop", "puzzleInfo" : " ", "puzzleFenStart" : "2rq1rk1/1b2bppp/pp1ppn2/8/PP2PP2/1QNPBN2/6PP/R4R1K b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "21 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "r2qrnk1/pp3pb1/3p4/2pPp1p1/2P1P3/2N2PBR/PPQ2P2/2KR4 w - - 0 51", "puzzleMoves" : "Rdh1 Ng6 Nd1 Rc8 Ne3 Rc7 Nf5", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "22 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "r3r1k1/pb2qppp/1n6/2b3PN/4p1QP/2N1P3/1P1B1P2/R3K2R b KQ - 0 51", "puzzleMoves" : "Nd7 Qg3 Bd6 Qg2 Ne5", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "23 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "r1q3k1/3nr1pp/p1p1p3/1p2P3/2P4R/5N2/P3QPPP/R5K1 w - - 0 51", "puzzleMoves" : "Ng5 h6 Ne4 Qc7 Nd6", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "24 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "1q1r1rk1/1b3ppp/p1npp3/2p5/2P1P3/1P2QBPP/PR2NP2/2R3K1 b - - 0 51", "puzzleMoves" : "e5 Bg2 Qa8 Nc3 Nd4 Nd5 Bxd5 cxd5", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "25 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "2rr2k1/pp1nbppp/4p2q/8/2PP2P1/7P/PB1NQPK1/2RR4 b - - 0 51", "puzzleMoves" : "Nf8 Qf3 Ng6 Kf1 f5", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "26 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "r1b2r1k/1pp3b1/p1nq3p/3p1p2/3P1Pp1/1NPB2P1/PPNQ2P1/R3R1K1 b - - 0 51", "puzzleMoves" : "Ne7 Be2 Ng8 Nc5 Nf6 Nd3 Ne4", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "27 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "4r3/pp1r1pk1/4qbnp/P4p1Q/1P1p4/5NP1/2R1PPBP/5RK1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "28 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "3r2k1/3n1pb1/p1qPr1pp/2p1p3/NpR3P1/1P2P3/PB4QP/3R2K1 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "29 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "r4rk1/4bppp/pqbp1n2/1p2pPB1/4P3/1BNQ4/PPP3PP/R4R1K w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "30 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "r2r2k1/pp2qppp/5n2/2p5/2Q5/P3PP2/1P4PP/R1B2RK1 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "31 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "r1r1n1k1/3nqp2/2p1p2p/1pPp2p1/1P1Pb3/5NP1/1Q2PP1P/R2RBBK1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "32 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "3rr1k1/4n1pp/1p1q1p2/p1pPp3/P1P1P2P/2P1B1P1/4Q2K/1R3R2 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "33 Knight", "puzzleInfo" : " ", "puzzleFenStart" : "r2b2k1/r4pp1/pq1p1n2/4pP2/R3P2p/1NN4P/RPP1Q1PK/8 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "41 Rook", "puzzleInfo" : " ", "puzzleFenStart" : "2bq1r1k/rp4pp/p1p3n1/5p2/3P4/1BP2N1P/PP4P1/R2Q1RK1 w - - 0 51", "puzzleMoves" : "Qd2 b5 Rae1 Qd6 Ne5 c5 Nxg6 hxg6 Qf2", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "42 Rook", "puzzleInfo" : " ", "puzzleFenStart" : "r1r3k1/p2qpp1p/np1p2p1/3P4/PP1QP3/4BP2/6PP/2RR2K1 w - - 0 51", "puzzleMoves" : "Rc6 Rxc6 dxc6 Qe6 Qc3", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "43 Rook", "puzzleInfo" : " ", "puzzleFenStart" : "3r1rk1/p3bppp/1pq1p3/2pnP3/8/2P2N2/PP2QPPP/R1B2RK1 b - - 0 51", "puzzleMoves" : "Rd7 Rd1 Rfd8 Bd2 b5", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "44 Rook", "puzzleInfo" : " ", "puzzleFenStart" : "2rq1rk1/pb1n1p1p/1p2pbp1/8/3PPB2/3B1N2/P3QPPP/2RR2K1 w - - 0 51", "puzzleMoves" : "Ba6 Bxa6 Qxa6 Rxc1 Rxc1 Qa8 Bd6 Rd8 e5", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "45 Rook", "puzzleInfo" : " ", "puzzleFenStart" : "nrr3k1/1p4pp/p2qpn2/PbNpNp2/3P1P2/4P3/1PQ2PBP/R1R3K1 w - - 0 51", "puzzleMoves" : "Ra3 Rc7 Rc3 Qe7 Bf1", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "46 Rook", "puzzleInfo" : " ", "puzzleFenStart" : "1qrr2k1/4npbp/4p1p1/3nP3/Np6/1P3NPP/PB2Q2K/2R1R3 b - - 0 51", "puzzleMoves" : "Bh6 Rc4 Ne3 Rcc1 N7d5", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "70 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3k2r/pp1nppbp/1qpp1np1/6B1/2PP3P/2N2P1B/PPQ1PP2/1K1R3R b kq - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "71 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3kb1r/1pp1qppp/p1bp1n2/4p3/P4P2/1P2P3/1BPPN1PP/RN1Q1RK1 b kq - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "72 King", "puzzleInfo" : " ", "puzzleFenStart" : "rnq1nbk1/1p3r1p/p2p2p1/2pPp1PP/P1P1Pp2/2N2N2/1P1B1P2/R2QK2R w KQ - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "73 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3k2r/pp1nqp2/3p1n2/2pP1b2/Q1P2p1p/2P5/P2NBBPP/R4RK1 b kq - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "74 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3k1r1/1pqb1p1p/p2ppn2/4n3/P2QP1pP/2N3P1/1PPN1PB1/R4RK1 b q - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "75 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3k2r/1bq1bppp/ppnppn2/8/P3PP2/1NNBBR2/1PP3PP/R2Q3K b kq - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "61 Queen", "puzzleInfo" : " ", "puzzleFenStart" : "2r1qbk1/3b1r2/p3p3/1p2Pp2/1n1N1Pp1/1PN3Pp/P2Q1B1P/2RR2K1 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "62 Queen", "puzzleInfo" : " ", "puzzleFenStart" : "3r3k/pp3p2/8/2p1q3/3n3r/P4PR1/1B3P1P/1Q4RK w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "63 Queen", "puzzleInfo" : " ", "puzzleFenStart" : "2k1r3/pppq4/2nbrpp1/3p1n2/3P1PNp/2PQ3P/PP1BN1P1/2K1RR2 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "64 Queen", "puzzleInfo" : " ", "puzzleFenStart" : "4r1k1/1p1qn2p/2p1bpp1/5p2/2PP2P1/1PBQ4/2B2PP1/R5K1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "65 Queen", "puzzleInfo" : " ", "puzzleFenStart" : "2r2r1k/1pqn2p1/1n1p3p/3P1p2/pPP5/P3b2P/QBR3P1/1N1R1B1K b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "66 Queen", "puzzleInfo" : " ", "puzzleFenStart" : "1r3rk1/Q4ppp/p1qN1b2/P7/1n2P3/4B3/6PP/3R1R1K w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "70 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3k2r/pp1nppbp/1qpp1np1/6B1/2PP3P/2N2P1B/PPQ1PP2/1K1R3R b kq - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "71 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3kb1r/1pp1qppp/p1bp1n2/4p3/P4P2/1P2P3/1BPPN1PP/RN1Q1RK1 b kq - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "72 King", "puzzleInfo" : " ", "puzzleFenStart" : "rnq1nbk1/1p3r1p/p2p2p1/2pPp1PP/P1P1Pp2/2N2N2/1P1B1P2/R2QK2R w KQ - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "73 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3k2r/pp1nqp2/3p1n2/2pP1b2/Q1P2p1p/2P5/P2NBBPP/R4RK1 b kq - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "74 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3k1r1/1pqb1p1p/p2ppn2/4n3/P2QP1pP/2N3P1/1PPN1PB1/R4RK1 b q - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "75 King", "puzzleInfo" : " ", "puzzleFenStart" : "r3k2r/1bq1bppp/ppnppn2/8/P3PP2/1NNBBR2/1PP3PP/R2Q3K b kq - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "82 Bishop pair", "puzzleInfo" : " ", "puzzleFenStart" : "3rr1k1/1b4p1/3ppb1p/1p6/3P1P2/2P4P/1P1NR1NK/R7 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "83 Bishop pair", "puzzleInfo" : " ", "puzzleFenStart" : "2rnnrk1/pp5p/3p4/2pP1p2/P1P1pP2/6P1/2PBB2P/R3R1K1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "84 Bishop pair", "puzzleInfo" : " ", "puzzleFenStart" : "3r1rk1/pp3ppp/4p3/4P3/4NP2/2Nbb1P1/PP5P/R2R3K b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "85 Bishop pair", "puzzleInfo" : " ", "puzzleFenStart" : "5r1k/pb1q2b1/1p1pp1rp/2p2p2/5P1B/1PPPN2Q/1P2R1PP/4R2K b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "86 Bishop pair", "puzzleInfo" : " ", "puzzleFenStart" : "rn5k/1p2qpp1/pB1pn2p/4p3/4P1Q1/1BP3P1/PP3P1P/3R2K1 w - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"}, { "puzzleTitle" : "87 Bishop pair", "puzzleInfo" : " ", "puzzleFenStart" : "2q2rk1/3nbppp/p1b1p3/Pnp5/1r2PP1P/N1N1B1P1/RP2Q1B1/4R1K1 b - - 0 51", "puzzleMoves" : "", "puzzleVariations" : " ", "puzzleSolutionComment" : "", "firstMoveEnable" : "false"} ] }; function getNumberOfWeek() { /* const today = new Date(); const firstDayOfYear = new Date(today.getFullYear(), 0, 1); const pastDaysOfYear = (today - firstDayOfYear) / 86400000; return Math.ceil((pastDaysOfYear + firstDayOfYear.getDay() + 1) / 7)-2; */ const maDate = new Date() var d = new Date(maDate.getFullYear(), maDate.getMonth(), maDate.getDate(), 0, 0, 0); var DoW = d.getDay(); d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu var ms = d.valueOf(); // GMT d.setMonth(0); d.setDate(4); // Thu in Week 1 return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1; } function buildPuzzlesQuotidien() { var weekNumMax=0; var filter=""; var dateNow = new Date(); var currentWeekNumber=getNumberOfWeek(); for (var i = 0; i < puzzlesQuotidien.puzzles.length; i++) { filter=puzzlesQuotidien.puzzles[i].filter; if(filter.length==0 || (filter>currentWeekNumber && (filter-currentWeekNumber)<49)){ console.log(i+" Escape Filter '"+filter+"' puzzleTitle="+puzzlesQuotidien.puzzles[i].puzzleTitle); continue; } //console.log("Filter '"+filter+"' puzzleTitle="+puzzlesQuotidien.puzzles[i].puzzleTitle); if(filter>weekNumMax){ weekNumMax=filter; } } console.log("weekNumMax="+weekNumMax); var puzzlesArray = puzzlesShortQuotidien.puzzles; var numDay = dateNow.getDay(); var weekday = new Array(7); weekday[0] = "Sunday";//Dimanche weekday[1] = "Monday";//Lundi weekday[2] = "Tuesday";//Mardi weekday[3] = "Wednesday";//Mercredi weekday[4] = "Thursday";//Jeudi weekday[5] = "Friday";//Vendredi weekday[6] = "Saturday";//Samedi //numDay=2;//Test console.log("numDay="+numDay +" -> "+ weekday[numDay]); for (var i = 0; i < openningsPuzzles.puzzles.length; i++) { filter=openningsPuzzles.puzzles[i].filter; //console.log("Filter opennings '"+filter+"' puzzleTitle="+openningsPuzzles.puzzles[i].puzzleTitle); if(filter==numDay){ puzzlesArray.push(openningsPuzzles.puzzles[i]); } } console.log("Add "+(puzzlesArray.length-puzzlesShortQuotidien.puzzles.length)+" openning puzzles"); puzzlesShortQuotidien.puzzles=puzzlesArray; } function buildPuzzlesQuotidienBig() { var weekNumMax=0; var filter=""; var dateNow = new Date(); var currentWeekNumber=getNumberOfWeek(); for (var i = 0; i < puzzlesQuotidien.puzzles.length; i++) { filter=puzzlesQuotidien.puzzles[i].filter; if(filter.length==0 || (filter>currentWeekNumber && (filter-currentWeekNumber)<49)){ console.log(i+" Escape Filter '"+filter+"' puzzleTitle="+puzzlesQuotidien.puzzles[i].puzzleTitle); continue; } //console.log("Filter '"+filter+"' puzzleTitle="+puzzlesQuotidien.puzzles[i].puzzleTitle); if(filter>weekNumMax){ weekNumMax=filter; } } var weekNumMin=weekNumMax-2; if(weekNumMin==-1){ weekNumMin=1; }else if(weekNumMin==0){ weekNumMin=1; } console.log("Create puzzle between week "+weekNumMin+" and "+weekNumMax + " currentWeekNumber="+currentWeekNumber); var puzzlesArray = puzzlesShortQuotidien.puzzles; //Add puzzle /* for (var i = 0; i < puzzlesQuotidien.puzzles.length; i++) { filter=puzzlesQuotidien.puzzles[i].filter; if(filter.length==0 || (filter>currentWeekNumber && (filter-currentWeekNumber)<49)){ console.log(i+" Escape Filter '"+filter+"' puzzleTitle="+puzzlesQuotidien.puzzles[i].puzzleTitle); continue; } if(currentWeekNumber==1 && (filter>49 || filter==1)){ puzzlesArray.push(puzzlesQuotidien.puzzles[i]); console.log("Filter 2 '"+filter+"' puzzleTitle="+puzzlesQuotidien.puzzles[i].puzzleTitle); }else if(currentWeekNumber==2 && (filter>50 || filter==1 || filter==2)){ puzzlesArray.push(puzzlesQuotidien.puzzles[i]); console.log("Filter 3 '"+filter+"' puzzleTitle="+puzzlesQuotidien.puzzles[i].puzzleTitle); }else if(currentWeekNumber>2 && filter>=weekNumMin){ puzzlesArray.push(puzzlesQuotidien.puzzles[i]); console.log("Filter '"+filter+"' puzzleTitle="+puzzlesQuotidien.puzzles[i].puzzleTitle); } } var puzzleSize = puzzlesArray.length; console.log("Add "+puzzleSize+" puzzles"); */ //Add opening training //openningsPuzzles var numDay = dateNow.getDay(); var weekday = new Array(7); weekday[0] = "Sunday";//Dimanche weekday[1] = "Monday";//Lundi weekday[2] = "Tuesday";//Mardi weekday[3] = "Wednesday";//Mercredi weekday[4] = "Thursday";//Jeudi weekday[5] = "Friday";//Vendredi weekday[6] = "Saturday";//Samedi //numDay=2;//Test console.log("numDay="+numDay +" -> "+ weekday[numDay]); for (var i = 0; i < openningsPuzzles.puzzles.length; i++) { filter=openningsPuzzles.puzzles[i].filter; //console.log("Filter opennings '"+filter+"' puzzleTitle="+openningsPuzzles.puzzles[i].puzzleTitle); if(filter==numDay){ puzzlesArray.push(openningsPuzzles.puzzles[i]); } if(numDay>0 && numDay<5 && filter==(numDay+1)){//Lundi à jeudi puzzlesArray.push(openningsPuzzles.puzzles[i]); console.log("Filter opennings 2 '"+filter+"' puzzleTitle="+openningsPuzzles.puzzles[i].puzzleTitle); }else if(numDay==5 && filter==(numDay-1)){//Vendredi puzzlesArray.push(openningsPuzzles.puzzles[i]); console.log("Filter opennings 3 '"+filter+"' puzzleTitle="+openningsPuzzles.puzzles[i].puzzleTitle); } } console.log("Add "+(puzzlesArray.length-puzzlesShortQuotidien.puzzles.length)+" openning puzzles"); puzzlesShortQuotidien.puzzles=puzzlesArray; } buildPuzzlesQuotidien(); var puzzlesChoice = [matingCastledKing, puzzlesFromMyGames,openningsPuzzles,chessTempoPuzzles,puzzlesShortQuotidien, puzzlesQuotidien, endgamePuzzles,masteringChessStrategy]; console.log("Load allPuzzles.js done !"); ///////////////////// FIN de allPuzzles.js//////////////////// // ////////////////////////////////////////////////////////// var board, currentPuzzle game = new Chess(), numCurrMove=0, numCurrPuzzle=0, currentPuzzleMoves=[''], titleEl = $('#idTitle') puzzleTitleEl = $('#idPuzzleInfo'); var puzzleIni = true; var puzzleRes=""; var puzzleFinish = false; var fenHisto=['']; var allFenHisto=['']; var puzzlesErrorsRef=['-1']; var puzzlesMoveErrorsRef=['-1']; var showAllSolution = false; var activateOrientation = true; var okKoSize = 16; var usePuzzleErrorRepeat = false; var firstMoveEnable = false; var iconPlay=''; var iconPause=''; var wrongFen = "8/8/8/8/8/8/8/8 w - - 0 1"; //var currentPuzzle; var lastMoveTime = new Date(); var puzzlesChoosen = 0;//Puzzles list choice = Owngames/book/etc. // do not pick up pieces if the game is over // only pick up pieces for the side to move var onDragStart = function(source, piece, position, orientation) { if (game.game_over() === true || (game.turn() === 'w' && piece.search(/^b/) !== -1) || (game.turn() === 'b' && piece.search(/^w/) !== -1)) { return false; } puzzleIni=false; lastMoveTime = new Date(); chronoContinue(); console.log("onDragStart end"); };//onDragStart var onDrop = function(source, target, piece, newPos, oldPos, orientation) { // see if the move is legal puzzleIni=false; var move = game.move({ from: source, to: target, promotion: 'q' // NOTE: always promote to a queen for example simplicity }); // illegal move if (move === null) return 'snapback'; updateStatus(newPos); console.log("onDrop end"); };//onDrop // update the board position after the piece snap // for castling, en passant, pawn promotion var onSnapEnd = function() { board.position(game.fen()); fenHisto.push(game.fen()); allFenHisto.push(game.fen()); console.log("fenHisto1 = "+fenHisto); };//onSnapEnd var updateStatus = function(newPos) { var status = ''; var reloadPuzzleAfterError = false; var puzzleSuccessfullFinished = false; lastMoveTime = new Date(); chronoContinue(); var moveColor = 'White'; if (game.turn() === 'b') { moveColor = 'Black'; } // checkmate? if (game.in_checkmate() === true) { status = 'Game over, ' + moveColor + ' is in checkmate.'; } // draw? else if (game.in_draw() === true) { status = 'Game over, drawn position'; } // game still on else { status = moveColor + ' to move'; // check? if (game.in_check() === true) { status += ', ' + moveColor + ' is in check'; } } var gamepgn = game.pgn()+''; var actualFen = ' '+game.fen()+''; if(gamepgn.indexOf(']')>0){ gamepgn=gamepgn.substr(gamepgn.indexOf(']')+1,gamepgn.length); if(gamepgn.indexOf(']')>0){ gamepgn=gamepgn.substr(gamepgn.indexOf(']')+1,gamepgn.length); } } console.log("numCurrMove="+numCurrMove+" firstMoveEnable="+firstMoveEnable); isYourTurnToPlay(numCurrMove); if((numCurrMove%2 == 0 && firstMoveEnable==false) || (numCurrMove%2 == 1 && firstMoveEnable==true)){ //test move //load last FEN //var isIni = numCurrMove===0; console.log("isIni ? "+puzzleIni + " numCurrMove="+numCurrMove); var lastFen = fenHisto[fenHisto.length-1]; console.log("fenHisto.length="+fenHisto.length+" lastFen="+lastFen) var moveToPlay = currentPuzzleMoves[numCurrMove]; console.log("moveToPlay1="+moveToPlay+" lastFen="+lastFen); var tesPlayerMove = new Chess(lastFen) tesPlayerMove.move(moveToPlay); //TODO relaod from historic fen, the move before player move. Load this fen in tesPlayerMove, play expected move and compare Fen var expectedFen = tesPlayerMove.fen(); var wrongColor = false; if (game.turn() === 'b' && expectedFen.indexOf(' b ')>0){ console.log("Expected black move"); }else if (game.turn() === 'w' && expectedFen.indexOf(' w ')>0){ console.log("Expected black move"); }else{ console.log("KOOO -> not same color !!!"); wrongColor=true; } if(expectedFen == lastFen || wrongColor === true){ //Bad FEN -> MAJ Fen console.log("KOOO -> expectedFen=lastFen -> "+expectedFen+" moveToPlay="+moveToPlay+" wrongColor="+wrongColor); var mv1 = currentPuzzleMoves[0]; tesPlayerMove.move(mv1); expectedFen = tesPlayerMove.fen(); console.log("KOOO mv1 -> "+mv1 + " newFen:"+expectedFen); if(firstMoveEnable){ var mv2 = currentPuzzleMoves[1]; tesPlayerMove.move(mv2); expectedFen = tesPlayerMove.fen(); console.log("KOOO mv2 -> "+mv2 + " newFen:"+expectedFen); } } console.log("expectedFen="+expectedFen + " game.fen()="+game.fen()); var moveOk = (expectedFen==game.fen()); var puzzleIniNewFirstMoveEnableFalse = numCurrMove==0 && currentPuzzle.firstMoveEnable=='false'; var puzzleIniNewFirstMoveEnableTrue = numCurrMove==1 && currentPuzzle.firstMoveEnable=='true'; var puzzleIniNew = puzzleIniNewFirstMoveEnableFalse || puzzleIniNewFirstMoveEnableTrue; console.log("puzzleIniNew="+puzzleIniNew + " puzzleIniNewFirstMoveEnableFalse="+puzzleIniNewFirstMoveEnableFalse+ " puzzleIniNewFirstMoveEnableTrue="+puzzleIniNewFirstMoveEnableTrue+" numCurrMove="+numCurrMove+" currentPuzzle.firstMoveEnable="+currentPuzzle.firstMoveEnable); var isBadMove = moveOk==false && puzzleIni==false; var playerNumMoveToShow = (numCurrMove/2)+1; if(playerNumMoveToShow%1==0.5){ playerNumMoveToShow=playerNumMoveToShow-0.5; } //var isBadMove = moveOk==false && puzzleIniNew==false; console.log("isBadMove="+isBadMove+" moveOk="+moveOk+" puzzleIni="+puzzleIni); if(isBadMove){ console.log("Bad move !! -> isBadMove="+isBadMove + " moveOk="+moveOk+" puzzleIni="+puzzleIni +" numCurrMove="+numCurrMove+" expectedFen="+expectedFen+" game.fen=" +game.fen()); addBadMoveToHisto(numCurrPuzzle, numCurrMove); if ( confirm( 'Bad move. Reload Puzzle ?' ) ) { // Code à éxécuter si le l'utilisateur clique sur "OK" reloadPuzzleAfterError=true; } else { // Code à éxécuter si l'utilisateur clique sur "Annuler" } puzzleRes = puzzleRes + ""+playerNumMoveToShow+"✘"; if(numCurrMove>2 && (numCurrMove%10==0 || numCurrMove%9==0)){ puzzleRes = puzzleRes + "
"; } $("#idPuzzleRes").html(puzzleRes); puzzleFinish = false; majEngineAnalyze(game.fen()); }else if(puzzleIni==false) { puzzleRes = puzzleRes + ""+playerNumMoveToShow+"✔"; if(numCurrMove>2 && (numCurrMove%10==0 || numCurrMove%9==0 )){ puzzleRes = puzzleRes + "
"; } $("#idPuzzleRes").html( puzzleRes); } console.log("expectedFen = "+expectedFen + " player move="+game.fen()+" Equals ? "+(moveOk)); // play next move numCurrMove=numCurrMove+1; console.log("play next move 1 | numCurrMove="+numCurrMove); moveToPlay = currentPuzzleMoves[numCurrMove]; console.log("moveToPlay2="+moveToPlay); console.log("Play : "+moveToPlay); fenHisto.push(game.fen()); allFenHisto.push(game.fen()); console.log("fenHisto2 = "+fenHisto); majEngineAnalyze(game.fen()); game.move(moveToPlay); alertOnMove(moveToPlay); console.log("board FEN : "+board.fen()); majEngineAnalyze(game.fen()); findMoveInMasterDb(); //Last puzzle Move ? console.log("numCurrMove="+numCurrMove+" currentPuzzleMoves.length="+currentPuzzleMoves.length+" isBadMove="+isBadMove); if(isBadMove==false && (numCurrMove+1)>=currentPuzzleMoves.length){ puzzleRes = puzzleRes + " Done!"; $("#idPuzzleRes").html( puzzleRes); puzzleFinish = true; if(puzzleIni==false){ puzzleSuccessfullFinished = true; if(currentPuzzle.puzzleSolutionComment.length>1){ alert("Commentaires sur la solution : "+currentPuzzle.puzzleSolutionComment); } } //onSnapEnd(); //Next(); } puzzleIni=false; }else{ fenHisto.push(game.fen()); allFenHisto.push(game.fen()); console.log("fenHisto3 = "+fenHisto); } numCurrMove=numCurrMove+1; console.log("play next move 2 | numCurrMove="+numCurrMove); puzzleIni=false; console.log("puzzleSuccessfullFinished="+puzzleSuccessfullFinished); if(puzzleSuccessfullFinished){ puzzleFinish=false; console.log("numCurrPuzzle : "+numCurrPuzzle+" allPuzzles.puzzles.length= "+allPuzzles.puzzles.length+" numCurrMove="+numCurrMove); /* if ( numCurrMove>1 && confirm( 'Bien joué : puzzle terminé ! Reload Puzzle ?' ) ) { Reload(); } else { Next(); }*/ if(usePuzzleErrorRepeat){ console.log("usePuzzleErrorRepeat="+usePuzzleErrorRepeat); for (var i = 1; i < puzzlesErrorsRef.length; i++) { var puzzleRef = puzzlesErrorsRef[i]; console.log("#"+i+" puzzleRef="+puzzleRef+" numCurrPuzzle="+numCurrPuzzle); if(puzzleRef==numCurrPuzzle){ console.log("Find move! test=" + (puzzlesErrorsRef.length>i+1)); if(puzzlesErrorsRef.length>i+1){ numCurrPuzzle = puzzlesErrorsRef[i+1]-1; }else{ numCurrPuzzle = puzzlesErrorsRef[i]-1; } $('#idPuzzlesErrorsList option:eq("'+numCurrPuzzle+'")').prop('selected', true); console.log("#"+i+" puzzleRef="+puzzleRef+" numNextCurrPuzzle-1="+numCurrPuzzle); } } } Next(); puzzleSuccessfullFinished=false; }//if(puzzleSuccessfullFinished){ if(reloadPuzzleAfterError){ Reload(); } reloadSolutionNextMoves(); };//updateStatus var cfg = { draggable: true, position: 'start', onDragStart: onDragStart, onDrop: onDrop, onSnapEnd: onSnapEnd };//cfg function Next() { console.log("Next numCurrPuzzle:" + numCurrPuzzle); if(numCurrPuzzle0){numCurrPuzzle--;} loadPuzzle(numCurrPuzzle); }//Previous function sideToPlay(){ console.log("sideToPlay"); var moveColor = 'Blanc'; var colorBtn; var fontBtnColor; if (game.turn() === 'b'){ moveColor = 'Noir'; board.orientation('black'); colorBtn="black"; fontBtnColor="white"; }else{ colorBtn="white"; fontBtnColor="black"; board.orientation('white'); } console.log("sideToPlay moveColor="+moveColor); $("#sideToPlay").prop("value",'Trait au '+moveColor); $("#sideToPlay").prop("style","background-color:"+colorBtn+";color:"+fontBtnColor); } function majSideToPlayFromCurrentFen(){ console.log("majSideToPlayFromCurrentFen "+game.turn()); if (game.turn() === 'b'){ board.orientation('black'); console.log("Side : Black"); }else{ board.orientation('white'); console.log("Side : White"); } } function showBestScore(){ //customSwitches var showScoreEnable = $('#customSwitches').prop('checked') ; console.log("showBestScore - showScoreEnable="+showScoreEnable); if(showScoreEnable){ var line; var fenToFind = game.fen(); for (var i = 0; i < stockfishAnalyze.length; i++) { line = stockfishAnalyze[i]; if(fenToFind == line[0]){ console.log("showBestScore Find FEN "+fenToFind); //idPuzzleRes $('#idPuzzleRes').html($('#idPuzzleRes').html()+"
Score:"+line[1][0][2]+" Profondeur:"+line[1][0][4]); break; } } } } function addBadMoveToHisto(refPuzzleKo, refMovveKo){ console.log("addBadMoveToHisto refPuzzleKo="+refPuzzleKo+" refMovveKo="+refMovveKo+" - "+puzzlesErrorsRef.length+" puzzles KO"); var alreadyKO = false; for (var i = 0; i < puzzlesErrorsRef.length; i++) { var badMove = puzzlesErrorsRef[i]; if(badMove==refPuzzleKo){ alreadyKO=true; console.log("Puzzle already KO"); break; } } if(!alreadyKO){ puzzlesErrorsRef.push(refPuzzleKo); puzzlesMoveErrorsRef.push(refMovveKo); } iniPuzzleErrorList(); } //List the detail of all puzzles function iniPuzzleList (){ console.log("iniPuzzleList "+allPuzzles.puzzles.length+" puzzles"); var selectHtml="\n\n"; $("#idPuzzleList").html(selectHtml); }//iniPuzzleList $('#idPuzzleList').on('change', function() { var optSelected=$(this).find(":selected").val(); console.log("OnChange idPuzzleList optSelected="+optSelected); loadPuzzle( optSelected); usePuzzleErrorRepeat=false; }); //List the detail of all puzzles function iniPuzzleErrorList (){ console.log("iniPuzzleErrorList "+puzzlesErrorsRef.length+" puzzles KO"); var selectHtml="\n\n"; $("#idPuzzlesErrorsList").html(selectHtml); }//iniPuzzleErrorList function selectedErrorPuzzle(){ console.log("selectedErrorPuzzle - numCurrPuzzle="+numCurrPuzzle); $('#idPuzzlesErrorsList option').each(function(idx, item) { console.log("selectedErrorPuzzle - #"+idx+" - value="+item.value); if(numCurrPuzzle==item.value){ console.log("selectedErrorPuzzle - Find puzzle "+numCurrPuzzle+" on error List"); item.selected=true; } }); } $('#idPuzzlesErrorsList').on('change', function() { var optSelected=$(this).find(":selected").val(); console.log("OnChange idPuzzleList optSelected="+optSelected); usePuzzleErrorRepeat=true; loadPuzzle( optSelected); }); function iniPuzzleChoiceList (){ console.log("iniPuzzleChoiceList "+puzzlesChoice.length+" puzzles"); var selectHtml="\n\n"; $("#idPuzzleChoice").html(selectHtml); }//iniPuzzleList //Choose the set of puzzle = from own games/from book / from opening repertory .. $('#idPuzzleChoice').on('change', function() { var optSelected=$(this).find(":selected").val(); console.log("OnChange idPuzzleChoice optSelected="+optSelected); puzzlesChoosen=optSelected; allPuzzles = puzzlesChoice[optSelected]; titleEl.html(allPuzzles.title + " - "+allPuzzles.puzzles.length+" puzzles"); numCurrPuzzle=0; numCurrMove=0; iniPuzzleList(); loadPuzzle(numCurrPuzzle); chronoStop(); chronoReset(); chronoStart(); puzzlesErrorsRef=['-1']; puzzlesMoveErrorsRef=['-1']; usePuzzleErrorRepeat=false; //numCurrMove=0; console.log("OnChange idPuzzleChoice END - numCurrMove="+numCurrMove); loadPuzzle(0); showBestScore(); }); function loadPuzzle(puzzleNumber){ console.log("loadPuzzle puzzleNumber="+puzzleNumber); currentPuzzle = allPuzzles.puzzles[puzzleNumber]; puzzleFinish = false; console.log("JSON : "+JSON.stringify(currentPuzzle)); console.log("puzzleTitle : "+currentPuzzle.puzzleTitle); currentPuzzleMoves=currentPuzzle.puzzleMoves.split(' '); console.log("currentPuzzleMoves : "+currentPuzzleMoves); puzzleTitleEl.html(currentPuzzle.puzzleTitle); var startFen = currentPuzzle.puzzleFenStart.trim(); loadFenToBoard(startFen); fenHisto=[startFen]; console.log("fenHisto4 = "+fenHisto); numCurrMove=0; puzzleIni = true; puzzleRes=""; firstMoveEnable = currentPuzzle.firstMoveEnable=='true'; console.log("firstMoveEnable = "+firstMoveEnable); if(activateOrientation===true && firstMoveEnable==false){ console.log("Orientation : normal"); if(startFen.indexOf(" b ")>0){ board.orientation('black'); }else{ board.orientation('white'); } }else if(activateOrientation===true && firstMoveEnable==true){ console.log("Orientation : affter move 1"); if(startFen.indexOf(" b ")>0){ board.orientation('white'); }else{ board.orientation('black'); } } $("#idPuzzleRes").html( puzzleRes); numCurrPuzzle=puzzleNumber; $('#idPuzzleList option[value="'+numCurrPuzzle+'"]').prop('selected', true); createPuzzleListMove=['']; //$("#idPuzzleSolutionComment").html(""); // $("#idPuzzleSolution").html(""); majEngineAnalyze(startFen); console.log("puzzleInfo : "+currentPuzzle.puzzleInfo); $("#idPuzzleInfo").html(currentPuzzle.puzzleInfo); $("#idAnalyseStockfish").hide(); $("#idAnalyseLeelaChessZero").hide(); $("#idPuzzleMasterStat").hide(); $("#idPuzzleSolution").hide(); showAllSolution=false; selectedErrorPuzzle(); if(firstMoveEnable===true){ numCurrMove=1; console.log("Load first Move numCurrMove="+numCurrMove+" firstMoveEnable="+firstMoveEnable); sleep(500); gameMove(currentPuzzleMoves[0]); majEngineAnalyze(game.fen()); }else{ console.log("Don't load first Move"); } sideToPlay(); puzzleIni = true; showBestScore(); generateOpeningInfo(); }//loadPuzzle function isYourTurnToPlay(numCurrMove){ console.log("isYourTurnToPlay"); var firstMoveEnable = currentPuzzle.firstMoveEnable; console.log("firstMoveEnable="+firstMoveEnable); var isYourTurn = false; if(firstMoveEnable){ isYourTurn= numCurrMove%2 == 0; }else{ isYourTurn= numCurrMove%2 == 1; } console.log("isYourTurn="+isYourTurn); } function Reload(){ loadPuzzle(numCurrPuzzle); }//Reload function loadFenToBoard(fenToLoad){ board.position(fenToLoad); game= new Chess(fenToLoad); } var createPuzzleListMove=['']; function LoadFenToCreatePuzzle(){ var fenToLoad = $("#fenToLoadId"). val(); console.log("fenToLoad="+fenToLoad); loadFenToBoard(fenToLoad); createPuzzleListMove=['']; $("#idPuzzleSolutionComment").html(""); $("#movesToLoadId").val(""); if(fenToLoad.indexOf(" b ")>0){ board.orientation('black'); }else{ board.orientation('white'); } }//LoadFenToCreatePuzzle function gameMove(move){ console.log("gameMove move="+move); console.log("gameMove - fen before="+game.fen()); if(wrongFen==game.fen()){ console.log("Wrong puzzle - reload '"+currentPuzzle.puzzleFenStart.trim()+"'"); game.fen(currentPuzzle.puzzleFenStart.trim()); console.log("gameMove 2 - fen before="+game.fen()); } game.move(move); console.log("gameMove - fen after="+game.fen()); board.position(game.fen(), true); }//gameMove function PlayMoves(){ board = ChessBoard('board'); board.position(game.fen(), false); var movesToPlay = $("#movesToLoadId"). val(); if(movesToPlay.indexOf(" ")>0){ console.log("gameMove - find multiple moves : '"+movesToPlay+"'"); var movesTab = movesToPlay.split(" "); for (var i = 0; i < movesTab.length; i++) { var theMoveToPlay=movesTab[i]; console.log("gameMove - Move "+i+" : '"+theMoveToPlay+"'"); if(theMoveToPlay.length<2){continue;} gameMove(theMoveToPlay); createPuzzleListMove.push(theMoveToPlay+" "); } }else{ console.log("gameMove - find one move : '"+movesToPlay+"'"); gameMove(movesToPlay); createPuzzleListMove.push(movesToPlay+" "); } $("#idPuzzleSolutionComment").html(createPuzzleListMove); var fenToLoad = $("#fenToLoadId"). val(); if(fenToLoad.length>0){ if(fenToLoad.indexOf(" b ")>0){ board.orientation('black'); }else{ board.orientation('white'); } } }//PlayMoves function sleep(milliseconds) { const date = Date.now(); let currentDate = null; do { currentDate = Date.now(); } while (currentDate - date < milliseconds); }//sleep function showSolution(){ console.log("showSolution"); //$("#idPuzzleSolution").html(currentPuzzle.puzzleMoves); reloadSolutionNextMoves(); if(showAllSolution == true){ $("#idAnalyseStockfish").show(); $("#idAnalyseLeelaChessZero").show() $("#idPuzzleMasterStat").show(); $("#idPuzzleSolution").show(); showAllSolution=false; findMoveInMasterDb(); }else{ $("#idAnalyseStockfish").hide(); $("#idAnalyseLeelaChessZero").hide() $("#idPuzzleMasterStat").hide(); $("#idPuzzleSolution").hide(); showAllSolution=true; } } function reloadSolutionNextMoves(){ console.log("reloadSolutionNextMoves currentPuzzle="+currentPuzzle); var movesTab=currentPuzzle.puzzleMoves.split(" "); var res = " "; //res=res+ ""; var nextMove=""; for (var i = 0; i < movesTab.length; i++) { if(i==numCurrMove){ res+= ""; } if(i>=numCurrMove){ nextMove=nextMove+" "+movesTab[i]; } res+=movesTab[i]+" "; } res="Solution : ("+currentPuzzle.puzzleTitle+")"+res; res+=""; $("#idPuzzleSolution").html(res); } function isNumeric(str) { if (typeof str != "string") return false // we only process strings! return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)... !isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail } function showAllFen(){ var allFen = ""; var allFenCopy = ""; var movesTab=['']; var moves; var fen; var subFen; var numFen=0; var tmpGame; var move; var puzzle; var numberFenExpected = 0; var currentPuzzlesListTemp; var errorsMsg=""; var nbErrors=0; var utc = new Date().toJSON(); allFen+='
//>Build Date : '+utc; for (var k = 0; k < puzzlesChoice.length; k++) { currentPuzzlesListTemp=puzzlesChoice[k]; console.log("PuzzleList "+k+" title:" + currentPuzzlesListTemp.title); allFen+='

/* ************'+"PuzzleList "+k+" title:" + currentPuzzlesListTemp.title+" *************** */"; for (var i = 0; i < currentPuzzlesListTemp.puzzles.length; i++) { puzzle = currentPuzzlesListTemp.puzzles[i]; console.log("#"+i+" puzzleTitle:" + puzzle.puzzleTitle); fen = puzzle.puzzleFenStart; var fenTrim = fen.trim(); if(fen.length>fenTrim.length){ nbErrors=nbErrors+1; errorsMsg+="\n ErrorA "+nbErrors+" on puzzle #"+i+" '"+currentPuzzlesListTemp.title+"' PuzzleTitle:'"+puzzle.puzzleTitle+"' puzzleInfo;"+puzzle.puzzleInfo+" Fen '"+fen+"' avec espace"; } var fenSplit = fen.trim().split(" "); var lastFenVal = fenSplit[fenSplit.length-1]; var lastFenValIsInteger = isNumeric(lastFenVal); if(fen.indexOf('-')==-1 || !lastFenValIsInteger ){ nbErrors=nbErrors+1; if(!lastFenValIsInteger){ errorsMsg+="\n Error Fen1 "+nbErrors+" on puzzle #"+i+" '"+currentPuzzlesListTemp.title+"' PuzzleTitle:'"+puzzle.puzzleTitle+"' puzzleInfo;"+puzzle.puzzleInfo+" Fen '"+fen+"' KO | lastFenVal='"+lastFenVal+"' lastFenValIsInteger="+lastFenValIsInteger; }else{ errorsMsg+="\n Error Fen2 "+nbErrors+" on puzzle #"+i+" '"+currentPuzzlesListTemp.title+"' PuzzleTitle:'"+puzzle.puzzleTitle+"' puzzleInfo;"+puzzle.puzzleInfo+" Fen '"+fen+"' KO"; } } allFen+='
//'+"#"+i+" puzzleTitle:" + puzzle.puzzleTitle; allFen+='
'+fen; moves = puzzle.puzzleMoves; movesTab = moves.split(" "); numberFenExpected+=movesTab.length; console.log("#"+i+" numberFenExpected:" + numberFenExpected); tmpGame = new Chess(fen); for (var j = 0; j < movesTab.length; j++) { move=movesTab[j]; if(move.length==0){continue;}//no moves in the puzzle (0 solution) if(move.length>5 && !(move.indexOf('?')>0) && !(move.indexOf('!')>0) && !(move.indexOf('x')>0 && move.indexOf('=')>0 && move.indexOf('+')>0) && !(move.indexOf('x')>0 && move.indexOf('#')>0) && !(move.indexOf('x')>0 && move.indexOf('+')>0) && !(move.indexOf('x')>0 && move.indexOf('=')>0) ){ nbErrors++; errorsMsg+="\n Error Move "+nbErrors+" on puzzle #"+i+" move:"+move+" '"+currentPuzzlesListTemp.title+"' PuzzleTitle:'"+puzzle.puzzleTitle+"' puzzleInfo;"+puzzle.puzzleInfo+" - i:"+i+" j:"+j+" k:"+k; } tmpGame.move(move); subFen = tmpGame.fen(); if (tmpGame.game_over() == true) { continue; } if(subFen==fen || fen=='8/8/8/8/8/8/8/8 w - - 0 1' || subFen=='8/8/8/8/8/8/8/8 w - - 0 1'){ nbErrors++; errorsMsg+="\n Error SubFen "+nbErrors+" on puzzle #"+i+" '"+currentPuzzlesListTemp.title+"' PuzzleTitle:'"+puzzle.puzzleTitle+"' puzzleInfo;"+puzzle.puzzleInfo+"- i:"+i+" j:"+j+" k:"+k; } numFen++; console.log("Puzzle "+i+"-"+j+" numFen="+numFen+" - PuzzleList "+k+" title:" + currentPuzzlesListTemp.title); allFen+=';'+subFen; } } } if(errorsMsg.length>0){ console.log(errorsMsg); alert(nbErrors+" errors : "+"\n"+errorsMsg); } //allFenCopy=allFen; //allFenCopy=replaceAll(allFen, '
', '\\n'); allFenCopy=replaceAll(allFen, '
', '\n'); //CopyTextToClipboard(allFenCopy); $("#idPuzzleSolution").html(numFen+" fen found!
"+allFen); $("#idPuzzleSolution").show(); } function replaceAll(str, find, replace) { return str.replace(new RegExp(find, 'g'), replace); } function majEngineAnalyze(fenToFind){ majStockfishAnalyze(fenToFind); majLeelaChessZeroAnalyze(fenToFind); } var lastStockfishAnalyze=""; function majStockfishAnalyze(fenToFind){ console.log("majStockfishAnalyze Load "+stockfishAnalyze.length+" fen"); var line; var analyseTable; var findMv = false; for (var i = 0; i < stockfishAnalyze.length; i++) { line = stockfishAnalyze[i]; if(fenToFind == line[0]){ findMv=true; console.log("majStockfishAnalyze Find FEN "+fenToFind); analyseTable=tabToHtml(line, "Stockfish"); $("#idAnalyseStockfish").html("
My Move Stockfish Analyse :
"+analyseTable+"
Last Opponent Move Stockfish Analyse :
"+lastStockfishAnalyze); break; } } if(findMv==false){ $("#idAnalyseStockfish").html("
No Stockfish analyze found"); } lastStockfishAnalyze=analyseTable; } function majLeelaChessZeroAnalyze(fenToFind2){ console.log("majLeelaChessZeroAnalyze Load "+leelaChessZeroAnalyze.length+" fen"); var line2; var analyseTable2; var findMv2 = false; for (var i = 0; i < leelaChessZeroAnalyze.length; i++) { line2 = leelaChessZeroAnalyze[i]; if(fenToFind2 == line2[0]){ findMv2=true; console.log("majLeelaChessZeroAnalyze Find FEN "+fenToFind2); analyseTable2=tabToHtml(line2, "Leela Chess Zero"); $("#idAnalyseLeelaChessZero").html("
My Move Leela Chess Zero Analyse :
"+analyseTable2); break; } } if(findMv2==false){ $("#idAnalyseLeelaChessZero").html("
No Leela Chess Zero analyze found"); } } var findMoveInMasterDb = function() { var findGames = false; var fenToSearch=game.fen().substr(0,game.fen().indexOf(' ')); console.log('Master db info ='+mastersGamesDbInfo); console.log('Master db ='+openingMastersUCI.length+' moves'); for (i = 0; i < openingMastersUCI.length; i++) { if(openingMastersUCI[i][0]==fenToSearch){ console.log('find fen in chess master DB '); //mastergames.html(openingMastersUCI[i][1]); $("#idPuzzleMasterStat").html("Master Stat. : "+dbMasterStatToHtml(openingMastersUCI[i])); findGames=true; break; } } if(findGames==false){$("#idPuzzleMasterStat").html('No master game found');} generateOpeningInfo(); } function dbMasterStatToHtml(masterMoves){ var masterMv; var html = ""; console.log("dbMasterStatToHtml masterMoves='"+masterMoves+"'"); var masterFontSize = 28; for (i = 0; i < masterMoves.length; i++) { if(i==0){continue;} masterMv = masterMoves[i]; console.log("dbMasterStatToHtml masterMv='"+masterMv+"'"); var move = masterMv[0]; var pourcentage = masterMv[1]; var nbOccurences = masterMv[2]; console.log("dbMasterStatToHtml move="+move+" pourcentage="+pourcentage+" nbOccurences="+nbOccurences); if(pourcentage>19){ html=html +"" +""+move+" "+pourcentage+"%("+nbOccurences+")"; }else if(pourcentage>9){ html=html +"" +" "+move+" "+pourcentage+"%("+nbOccurences+")"; }else{ html=html+" "+move+" "+pourcentage+"%("+nbOccurences+")"; } } console.log("dbMasterStatToHtml html="+html); return html; } function generateOpeningInfo(){ var findOpening=false; var fenToSearch=game.fen().substr(0,game.fen().indexOf(' ')); console.log("generateOpeningInfo fenToSearch='"+fenToSearch+"'"); var htmlRes=''; var openningVar=""; for (i = 0; i < fenToEco.length; i++) { var fen = fenToEco[i][0].substr(0,game.fen().indexOf(' ')); //console.log("fen='"+fen+"' fenToSearch='"+fenToSearch+"'"); if(fen==fenToSearch){ console.log('Find ECO : '+fenToEco[i]); if(fenToEco[i][3].length>1){ openningVar=" > "+fenToEco[i][3]; } htmlRes="ECO:"+fenToEco[i][1]+" > "+fenToEco[i][2]+openningVar+""; console.log('Find ECO HTML='+htmlRes); $('#openingInfoId').html(htmlRes); findOpening=true; break; } } if(findOpening==false){ console.log("generateOpeningInfo Fen not found in Db"); $('#openingInfoId').html(""); } //opningName } async function playMasterMoves(movesToPLay, speed){ console.log('playMasterMoves '+movesToPLay, " speed="+speed); var currentBoardFen = game.fen(); game.move(movesToPLay, {sloppy: true}); board.position(game.fen()); await sleep(speed); var findGames = false; for (j = 0; j < 10; j++) { var fenToSearch=game.fen().substr(0,game.fen().indexOf(' ')); for (i = 0; i < openingMastersUCI.length; i++) { if(openingMastersUCI[i][0]==fenToSearch){ findGames=true; console.log(i+'# find fen in chess master DB '); game.move(openingMastersUCI[i][1][0], {sloppy: true}); board.position(game.fen()); await sleep(speed); break; } } if(findGames==false){ break; } await sleep(speed); } await sleep(7000); board.position(currentBoardFen); game= new Chess(currentBoardFen); } document.getElementById("movesToLoadId").onkeypress = function(event){ if (event.keyCode == 13 ){//|| event.which == 13){ console.log("movesToLoadId-You are pressed enter"); // if($(this).val().indexOf(" ")>0){ //split n moves // }else{ PlayMoves(); // } $(this).val(''); } }; document.getElementById("fenToLoadId").onkeypress = function(event){ if (event.keyCode == 13 ){//|| event.which == 13){ console.log("fenToLoadId-You are pressed enter"); LoadFenToCreatePuzzle(); } }; function ReversePuzzleOrder(){ allPuzzles.puzzles.reverse(); iniPuzzleList(); numCurrPuzzle=0; numCurrMove=0; loadPuzzle(numCurrPuzzle); chronoReset(); } function puzzleCreator(){ $("#idBuildPuzzle").toggle(); $("#idAnalyseStockfish").hide(); $("#idAnalyseLeelaChessZero").hide(); $("#idPuzzleMasterStat").hide(); $("#idPuzzleSolution").hide(); $("#idTitle").html("Puzzle creator"); } function changeChessBoardSize(size){ console.log('Change chessnboard size to '+size+' px'); document.getElementById('board').style='width:'+size+'px;float: none !important;margin-left: auto;margin-right: auto;' board.resize(); } function CopyTextToClipboard() { // Create a "hidden" input var aux = document.createElement("input"); // Assign it the value of the specified element var fenToCopy = game.fen(); aux.setAttribute("value", fenToCopy); // Append it to the body document.body.appendChild(aux); // Highlight its content aux.select(); // Copy the highlighted text document.execCommand("copy"); // Remove it from the body document.body.removeChild(aux); alert('FEN '+fenToCopy+' copied to clipboard !' ); } function CopyTextToClipboardFromVar(txtToCopy) { // Create a "hidden" input var aux = document.createElement("input"); // Assign it the value of the specified element aux.setAttribute("value", txtToCopy); // Append it to the body document.body.appendChild(aux); // Highlight its content aux.select(); // Copy the highlighted text document.execCommand("copy"); // Remove it from the body document.body.removeChild(aux); alert('txtToCopy= '+txtToCopy+' copied to clipboard !' ); } async function Play(movesToPLay, speed){ //var movesToPLay='c3b1 c2b2 h8g8 f1b1 b7b5 h1g1 e6c4 g2f1 f8f7 f1c4 b5c4 b2e2 c4c3 e2c4 d8f8 f2f4'; console.log('Play '+movesToPLay); var currentBoardFen = game.fen(); const moves = movesToPLay.split(' '); for (i = 0; i < moves.length; i++) { var move = moves[i]; console.log('Play '+move); var mvBoard = move.slice(0, 2) + "-" + move.slice(2); console.log('mvBoard '+mvBoard); game.move(move, {sloppy: true}); board.position(game.fen()); await sleep(speed); } await sleep(7000); board.position(currentBoardFen); game= new Chess(currentBoardFen); } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function tabToHtml(myTab, engine){ // ["5rBk/5pp1/5q2/8/8/8/2Q5/4K2R b K - 1 1", // [[1,1,"Mate -2","f6h6",27,"f6h6 h1h6 g7h6 c2h7"] // ,[2,2,"Mate -2","f6h4",27,"f6h4 h1h4 h8g8 c2h7"] // ,[3,3,"Mate -1","h8g8",27,"h8g8 c2h7"]]], console.log('tabToHtml myTab='+myTab); var allMoves = myTab[1]; var tab="
FEN"+myTab[0] +"
Next "+engine+" best moves :("+allMoves[0][6]+" | version:"+ allMoves[0][7]+" | Net:"+ allMoves[0][8]+")"; var colorStyle for (i = 0; i < allMoves.length; i++) { var mvCp = allMoves[i][2]; var mvDepth = allMoves[i][4]; var engineVersion = "engine:"+ allMoves[i][6]+" version:"+ allMoves[i][7]+" Network:"+ allMoves[i][8]; if(i>2){ tab+=""; }else{ tab+=""; } //# tab+="";//# //Move if(i===0){ tab+="";//Move }else{ tab+="";//Move } //CP if(mvCp<0 && i<3){ tab+="";//CP }else if(i<3 && mvCp>50){ tab+="";//CP }else{ tab+="";//CP } //Depth if(mvDepth<30 && i<3){ tab+="";//Depth }else{ tab+="";//Depth } var shortPv = getShortPv(allMoves[i][5]); console.log("tabToHtml shortPv='"+shortPv+"'"); //Next engine moves tab+=""; tab+="" ; } return tab+"
#MoveCPDepthNext engine moves
["+allMoves[i][1]+"]"+allMoves[i][3]+""+allMoves[i][3]+""+mvCp+""+mvCp+""+mvCp+""+mvDepth+""+mvDepth+"" +"" +"" +"" +shortPv+"
"; } function getShortPv(pv){ var movesTab = pv.split(" "); var nbMxMv = 12; if(movesTab.length0){ // board.orientation('black'); // }else{ // board.orientation('white'); // } } //EXECUTE COMMANDS board = ChessBoard('board', cfg); var allPuzzles = puzzlesChoice[puzzlesChoosen]; numCurrPuzzle=0; numCurrMove=0; loadPuzzle(numCurrPuzzle); updateStatus(); console.log(JSON.stringify(allPuzzles)); titleEl.html(allPuzzles.title + " - "+allPuzzles.puzzles.length+" puzzles"); $("#idBuildPuzzle").hide(); $("#idAnalyseStockfish").hide(); $("#idPuzzleSolution").hide(); $("#idAnalyseLeelaChessZero").hide(); iniPuzzleList(); iniPuzzleChoiceList(); numCurrMove=0; console.log("EXECUTE COMMANDS END - numCurrMove="+numCurrMove); loadPuzzle(0); //feather.replace(); //////////////////////////////////CHRONO/////////////// var startTime = 0; var start = 0; var end = 0; var diff = 0; var timerID = 0; window.onload = chronoStart; function chrono(){ end = new Date(); diff = end - start; diff = new Date(diff); var msec = diff.getMilliseconds(); var sec = diff.getSeconds(); var min = diff.getMinutes(); var hr = diff.getHours()-1; if (min < 10){ min = "0" + min; } if (sec < 10){ sec = "0" + sec; } if(msec < 10){ msec = "00" +msec; } else if(msec < 100){ msec = "0" +msec; } if(sec>0 && sec%10==0 && msec<500){ var diffLastMove=new Date()-lastMoveTime; var nbMinutesMax=4; if(diffLastMove>(1000*60*nbMinutesMax)){ var isPause = isPause(); console.log("Stop Chrono since "+nbMinutesMax+" minutes - no action since "+diffLastMove+" ms - start:"+start+" isPause="+isPause+" crono="+hr + ":" + min + ":" + sec + ":" + msec); if (!isPause ) { start = new Date(start.getTime()-(1000*60*nbMinutesMax)); } console.log("start:"+start+" isPause="+isPause); document.getElementById("chronotime").value = hr + ":" + min + ":" + sec + ":" + msec; chronoStop(); isPause = isPause(); console.log("isPause="+isPause); return; }else if(sec>0 && sec%10==0){ //console.log('chrono - diffLastMove='+diffLastMove); } } document.getElementById("chronotime").value = hr + ":" + min + ":" + sec + ":" + msec; timerID = setTimeout("chrono()", 100); } function isPause(){ return $("#startstop").html().indexOf(iconPause)==-1; } function chronoStart(){ console.log("chronoStart"); document.chronoForm.startstop.value = "pause!"; //// iconPlay iconPause relaodIconLib() // // $("#startstop").html(iconPause); relaodIconLib(); document.chronoForm.startstop.onclick = chronoStop; document.chronoForm.reset.onclick = chronoReset; start = new Date(); chrono(); lastMoveTime = new Date(); } function chronoContinue(){ console.log("chronoContinue"); //document.chronoForm.startstop.value = "pause!"; //// iconPlay iconPause relaodIconLib() $("#startstop").html(iconPause); relaodIconLib(); document.chronoForm.startstop.onclick = chronoStop; document.chronoForm.reset.onclick = chronoReset; start = new Date()-diff; start = new Date(start); lastMoveTime = new Date(); chrono(); } function chronoReset(){ console.log("chronoReset"); document.getElementById("chronotime").value = "0:00:00:000"; start = new Date(); lastMoveTime = new Date(); } function alertOnMove(move){ if(move==undefined)return; //"!", "?", "!!", "!?", "?!", et "??" /* 1 good move (traditional "!") : bon coup 2 poor move (traditional "?") : mauvais coup 3 very good move (traditional "!!") : coup excellent 4 very poor move (traditional "??") : très mauvais coup 5 speculative move (traditional "!?") : coup spéculatif 6 questionable move (traditional "?!") : coup douteux */ if(move.indexOf("??")>0){ alert('Très mauvais coup adverse !'); }else if(move.indexOf("!!")>0){ alert('Coup adverse excellent !'); }else if(move.indexOf("?!")>0){ alert('Coup adverse douteux !'); }else if(move.indexOf("!?")>0){ alert('Coup adverse spéculatif !'); }else if(move.indexOf("!")>0){ alert('Coup adverse bon !'); }else if(move.indexOf("?")>0){ alert('Mauvais coup adverse!'); } } function chronoStopReset(){ console.log("chronoStopReset"); document.getElementById("chronotime").value = "0:00:00:000"; document.chronoForm.startstop.onclick = chronoStart; lastMoveTime = new Date(); } function chronoStop(){ console.log("chronoStop"); document.chronoForm.startstop.value = "start!"; // iconPlay iconPause relaodIconLib() $("#startstop").html(iconPlay); relaodIconLib(); document.chronoForm.startstop.onclick = chronoContinue; document.chronoForm.reset.onclick = chronoStopReset; clearTimeout(timerID); lastMoveTime = new Date(); } function relaodIconLib(){ // feather.replace(); } $(document).keydown(function(e) { //   //   if(e.keyCode===37){Previous();} if(e.keyCode===39){Next();} });